<template>
	<view class="page" style="padding-bottom: 50rpx;">
		<view class="topVue">
			<view class="safeVue" :style="{ height: statusBarHeight + 'rpx' }"></view>
			<view class="flex align-center padding-row30" :style="{ height: barHeight + 'rpx', top: statusBarHeight + 'rpx' }" @click="$tools.back()">
				<image src="../../static/back.png" style="width: 48rpx; height: 48rpx;"></image>
				<text style="line-height: 1; color: #454545; font-weight: 600; font-size: 32rpx; padding-left: 20rpx;">接单人信息</text>
			</view>
		</view>
		<view :style="{ height: statusBarHeight + barHeight + 'rpx' }"></view>
		<view class="item margin20 flex align-center">
			<view class="avatar">
				<image :src="detail.imgBody" style="width: 100%; height: 100%;"></image>
			</view>
			<view class="flex-1 flex-column padding-row30">
				<view class="name">姓名：{{ detail.workerName }}</view>
				<view class="name">性别：{{ detail.sex==0 ? "男" : "女" }}</view>
			</view>
		</view>
		<view class="label flex align-center"></view>
		<view class="li margin20 flex align-center">手机号：{{detail.phoneNo}} <view class="btn1" @click="phoneCall(detail.phoneNo)">拨打电话</view></view>
		<view class="li margin20">住宿地址： {{detail.address}}</view>
		<view class="lii margin20">
			<image :src="detail.imgLicense" mode=""></image>
		</view>
		<view class="lii margin20 padding20">
			{{detail.description}}
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				statusBarHeight: 0,
				barHeight: 0,
				menuHeight: 0,
				workerId: "",
				detail: {
					sex: "",
					workerName: "",
					phoneNo: "",
					address: "",
					imgBody: "",
					imgLicense: ""
				}
			}
		},
		async onLoad(option) {
			this.workerId = option.value
			console.log(this.status)
			let that = this;
			wx.getSystemInfo({
				success(res) {
					let deviceWidth = wx.getSystemInfoSync().windowWidth
					that.statusBarHeight = Number(res.statusBarHeight) * ( 750 / deviceWidth ) 
					let menuButtonInfo = wx.getMenuButtonBoundingClientRect()
					that.menuHeight = Number(menuButtonInfo.height) * ( 750 / deviceWidth )
					let barHeight = menuButtonInfo.height + (menuButtonInfo.top - res.statusBarHeight) * 2
					that.barHeight = Number(barHeight) * ( 750 / deviceWidth )
				},
			});
		},
		
		async onShow() {
			await this.getList()
		},
		
		methods: {
			async getList(){
				console.log("kkkk")
				const res = await this.$request(`/api/WeChat/homecareWorkerDetail?workerId=${this.workerId}`, {
					workerId: this.workerId
				}, 'GET')
				if(res.code===200) {
					console.log(res)
					this.detail = res.data
				}
			},
			phoneCall(phone){
				uni.makePhoneCall({
					phoneNumber: phone //仅为示例
				});
			},
		},
	}
</script>

<style lang="less" scoped>
	.topVue {
		width: 100%;
		background: #fff;
		position: fixed;
		left: 0;
		top: 0;
		z-index: 99;
		.safeVue {
			width: 100%;
		}
	}
	.lii {
		width: 690rpx;
		height: 240rpx;
		background: #f5f5f5;
		border-radius: 10rpx;
		text {
			color: #333;
			line-height: 40rpx;
		}
	}
	.li {
		width: 690rpx;
		height: 88rpx;
		border: 1rpx solid #f5f5f5;
		color: #454545;
		font-size: 32rpx;
		line-height: 88rpx;
		padding-left: 20rpx;
		border-radius: 10rpx;
		.btn1 {
			width: 150rpx;
			height: 66rpx;
			background: #D37430;
			border-radius: 10rpx;
			line-height: 66rpx;
			text-align: center;
			color: #fff;
			margin-left: 30rpx;
		}
	}
	.item {
		width: 690rpx;
		background: #fff;
		border-radius: 20rpx;
		box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(178, 178, 178, 0.25), inset 0rpx 8rpx 8rpx 0rpx rgba(255, 255, 255, 0.25);
		.avatar {
			width: 180rpx;
			height: 180rpx;
			background: #f5f5f5;
		}
		.name {
			width: 400rpx;
			height: 70rpx;
			border: 1rpx solid #f5f5f5;
			color: #454545;
			font-size: 32rpx;
			line-height: 70rpx;
			padding-left: 20rpx;
			border-radius: 10rpx;
			margin: 10rpx 0;
		}
	}
</style>